const express = require('express');
const router = express.Router();
const userController = require('../controllers/userController');
const auth = require('../middleware/auth');
const admin = require('../middleware/admin');

// 用户注册
router.post('/register', userController.register);

// 用户登录
router.post('/login', userController.login);

// 获取当前登录用户信息
router.get('/current', auth, userController.getCurrentUser);

// 获取所有用户(仅管理员)
router.get('/', auth, admin, userController.getAllUsers);

// 更新用户角色(仅管理员)
router.put('/role', auth, admin, userController.updateUserRole);

// 删除用户(仅管理员)
router.delete('/:id', auth, admin, userController.deleteUser);

module.exports = router;